<!--
    报警警情
 * @Author: zhanbh
 * @Date: 2021-04-08 10:46:41
 * @project: 天津YQ平台
-->
<template>
  <div class="info-110">
    <el-form ref="form" label-width="80px">
      <div class="table-filter table-filter-home">
        <div>
          <el-form-item label="发布时间:">
            <el-date-picker
              v-model="publishTime"
              clearable
              type="datetimerange"
              value-format="yyyyMMddHHmm"
              format="yyyy-MM-dd HH:mm"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-time="['00:00:00']"
            />
          </el-form-item>
        </div>
        <div>
          <el-form-item label="最晚反馈时间:" label-width="120px">
            <el-date-picker
              v-model="time"
              clearable
              type="datetimerange"
              value-format="yyyyMMddHHmm"
              format="yyyy-MM-dd HH:mm"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-time="['00:00:00']"
            />
          </el-form-item>
        </div>
        <div>
          <el-form-item label="关键词:">
            <el-input v-model="condition.keyword.value" placeholder="报警内容"  clearable />
          </el-form-item>
        </div>
        <div></div>
        <div></div>
        <div>
          <el-form-item class="operate-btns">
            <el-button type="primary" size="mini" @click="() => $refs.table.searchForm()"> 查询 </el-button>
            <el-button size="mini" @click="reset">重置</el-button>
          </el-form-item>
        </div>
      </div>
    </el-form>
    <div class="info-110__list">
      <comm-table ref="table" :condition="condition" :columns="columns" url="/v1/jqxx-ypzl/statsearch"> </comm-table>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex';
import { deepClone } from '@/utils/common';
import { BM_YPZT,BM_DEPT } from '@/common/codeDic';

export default {
  name: 'PoliceJudgeOrder',
  data() {
    return {
      publishTime: [],
      time: [],
      checkedYP: [],
      isImmerYP: false,
      checkAllYP: false,
      checkedXF: [],
      isImmerXF: false,
      checkAllXF: false,
      cloneCondition: null,
      columns: [
        { label: '序号', type: 'index' },
        { label: '发布时间', prop: 'fbsj', width: 180 },
        { label: '指令要求', prop: 'zlyq' },
        {
          label: '关联警情',
          render: (h, row) => {
            const _this = this;
            return h(
              'div',
              {
                class: 'v-link',
                on: {
                  click() {
                    // 隐藏tooltip(由于不自动消失)
                    $('.el-tooltip__popper').css('display', 'none');
                    _this.$router.push({ name: 'PolicJudgeOrderDetail', params: { id: row.jqxxbh } });
                  }
                }
              },
              row.bjnr
            );
          }
        },
        { label: '最晚反馈时间', prop: 'zwfksj' },
        {
          label: '发布单位',
          prop: 'fbdwdm',
          code:BM_DEPT
        },
        { label: '发布人', prop: 'fbrxm', code: BM_YPZT },
        {
          label: '签收情况',
          render: (h, row) => h('div', {}, [h('span', {}, `${row.signinSize || 0}/${row.ypzlSize || 0}`)])
        },
        {
          label: '反馈情况',
          render: (h, row) => h('div', {}, [h('span', {}, `${row.feedbackSize || 0}/${row.ypzlSize || 0}`)])
        }
      ],
      condition: {
        keyword: {
          value: '',
          op: 'like'
        },
        fbsj: {
          value: '',
          op: 'custom_rangeDateTime'
        },
        zwfksj: {
          value: '',
          op: 'custom_rangeDateTime'
        }
      }
    };
  },
  computed: {
    ...mapState(['constant'])
  },
    activated(){
    this.$refs.table.searchForm()
  },
  watch: {
    time(val) {
      this.condition.zwfksj.value = val ? `${val[0]},${val[1]}` : '';
    },
    publishTime(val) {
      this.condition.fbsj.value = val ? `${val[0]},${val[1]}` : '';
    }
  },
  mounted() {
    this.cloneCondition = deepClone(this.condition);
  },
  methods: {
    reset() {
      this.time = null;
      this.publishTime = null;
      this.condition = deepClone(this.cloneCondition);
      this.$nextTick(() => {
        this.$refs.table.searchForm();
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.info-110 {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 11rem);
  overflow: hidden;
  .check-box {
    display: flex;
    /deep/.checkbox-group {
      text-align: left;
    }
    /deep/ .el-checkbox {
      margin-right: 6px;
    }
  }
  &__list {
    flex-shrink: 1;
    flex-grow: 1;
    margin-top: 10px;
    background-color: #fff;
    padding: 1.5rem 2rem;
  }
}
</style>
